package com.employ.job.service.impl;

import java.util.List;

import com.employ.common.core.domain.entity.SysUser;
import com.employ.common.utils.DateUtils;
import com.employ.job.domain.EmpJobs;
import com.employ.job.mapper.EmpJobsMapper;
import com.employ.system.mapper.SysLogininforMapper;
import com.employ.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.employ.job.mapper.EmpApplicationsMapper;
import com.employ.job.domain.EmpApplications;
import com.employ.job.service.IEmpApplicationsService;

/**
 * 职位申请Service业务层处理
 *
 * @author ruoyi
 * @date 2025-02-24
 */
@Service
public class EmpApplicationsServiceImpl implements IEmpApplicationsService
{
    @Autowired
    private EmpApplicationsMapper empApplicationsMapper;

    @Autowired
    private EmpJobsMapper empJobsMapper;

    @Autowired
    private SysUserMapper sysUserMapper;



    /**
     * 查询职位申请
     *
     * @param id 职位申请主键
     * @return 职位申请
     */
    @Override
    public EmpApplications selectEmpApplicationsById(Long id)
    {
        return empApplicationsMapper.selectEmpApplicationsById(id);
    }

    /**
     * 查询职位申请列表
     *
     * @param empApplications 职位申请
     * @return 职位申请
     */
    @Override
    public List<EmpApplications> selectEmpApplicationsList(EmpApplications empApplications)
    {
        List<EmpApplications> empApplicationsList = empApplicationsMapper.selectEmpApplicationsList(empApplications);
        for (EmpApplications empApplications1 : empApplicationsList) {
            EmpJobs empJobs = empJobsMapper.selectEmpJobsById(empApplications1.getJobId());
            SysUser sysUser = sysUserMapper.selectUserById(empApplications1.getStudentId());
            empApplications1.setJobName(empJobs.getTitle());
            empApplications1.setStudentName(sysUser.getNickName());
        }
        return empApplicationsList;
    }

    /**
     * 新增职位申请
     *
     * @param empApplications 职位申请
     * @return 结果
     */
    @Override
    public int insertEmpApplications(EmpApplications empApplications)
    {
        empApplications.setCreateTime(DateUtils.getNowDate());
        return empApplicationsMapper.insertEmpApplications(empApplications);
    }

    /**
     * 修改职位申请
     *
     * @param empApplications 职位申请
     * @return 结果
     */
    @Override
    public int updateEmpApplications(EmpApplications empApplications)
    {
        empApplications.setUpdateTime(DateUtils.getNowDate());
        return empApplicationsMapper.updateEmpApplications(empApplications);
    }

    /**
     * 批量删除职位申请
     *
     * @param ids 需要删除的职位申请主键
     * @return 结果
     */
    @Override
    public int deleteEmpApplicationsByIds(Long[] ids)
    {
        return empApplicationsMapper.deleteEmpApplicationsByIds(ids);
    }

    /**
     * 删除职位申请信息
     *
     * @param id 职位申请主键
     * @return 结果
     */
    @Override
    public int deleteEmpApplicationsById(Long id)
    {
        return empApplicationsMapper.deleteEmpApplicationsById(id);
    }
}
